<template>
	<view>
		<view style="width:100%;">
			<u-notice-bar :text="noticeList" direction="column" :customStyle="{'padding':'14rpx 10rpx;'}">
			</u-notice-bar>
		</view>

		<view class="template-view">
			<view class="address-view flex-between items-center" @click="$uti.toPage('/pages/address/list',{type:0})">
				<view>
					<view class="address-tag" style="background: #00d969;color:#fff;">
						寄
					</view>
				</view>
				<view style="margin-left: 10rpx;width:80%;">
					<view class="user-info">
						{{seller.userName || '暂无地址'}} {{seller.phone || ''}}
					</view>
					<view class="address-info">
						{{seller.state || '点击选择地址'}}{{seller.city || ''}}{{seller.street || ''}}{{seller.detailed || ''}}
					</view>
				</view>
				<view>
					<u-icon name="arrow-right" size="16"></u-icon>
				</view>
			</view>
			<view style="width:84%;height: 2rpx;background: #eee;margin:20rpx 0rpx;left:8%;position: relative;">

			</view>
			<view class="address-view flex-between items-center" @click="$uti.toPage('/pages/address/list',{type:1})">
				<view>
					<view class="address-tag" style="background: #3c9cff;color:#fff;">
						收
					</view>
				</view>
				<view style="margin-left: 10rpx;width:80%;">
					<view class="user-info">
						{{query.userName || '暂无地址'}} {{query.phone || ''}}
					</view>
					<view class="address-info">
						{{query.state || '点击选择地址'}}{{query.city || ''}}{{query.street || ''}}{{query.detailed || ''}}
					</view>
				</view>
				<view>
					<u-icon name="arrow-right" size="16"></u-icon>
				</view>
			</view>
			<view v-if="reason" class="flex-center"
				style="width:100%;background: rgba(255,0,0,0.3);color:#fff;font-size: 26rpx;border-radius: 20rpx;margin-top: 20rpx;padding:10rpx 0rpx;">
				<u-icon name="info-circle-fill" color="#fff" :label="'当前地址不可发货/收货，原因是'+reason+'！'" labelColor="#fff"
					labelSize="12"></u-icon>
			</view>
		</view>

		<view class="template-view">
			<u-cell-group :border="false">
				<u-cell :border="false" title="选择车辆" :customStyle="{'padding':'20rpx 0rpx;'}">
					<view slot="right-icon" @click="showCarType">
						<u-icon name="arrow-right" :label="file" labelPos="left" size="16"></u-icon>
						<!-- <view class="flex-end items-center" style="flex-wrap: wrap;">
							<view style="margin-bottom: 10rpx;margin-left: 10rpx;" v-for="(item,index) in columns[0]" :key="index">
								<u-tag type="primary" :plain="true"
									:text="item" size="mini"></u-tag>
							</view>
						</view> -->

					</view>
				</u-cell>

				<u-cell :border="false" title="预约时间" :customStyle="{'padding':'20rpx 0rpx;'}">
					<view slot="right-icon" @click="createOrderTime">
						
						<u-icon name="arrow-right" :label="dateData?dateData:'现在'" labelPos="left" size="16"></u-icon>


					</view>
				</u-cell>
				<!-- 	<u-cell :border="false" title="重量(KG)" :customStyle="{'padding':'20rpx 0rpx;'}">
					<view slot="right-icon">
						<u-number-box v-model="weight" @change="valChange" color="indianred" iconStyle="indianred">
						</u-number-box>
					</view>
				</u-cell> -->
				<u-cell :border="false" title="体积" :customStyle="{'padding':'20rpx 0rpx;'}">
					<view slot="right-icon">
						<view class="flex-center items-center" style="font-size: 24rpx;color:indianred;">
							长(CM)
							<u-input type="number" placeholder="CM" border="bottom" :customStyle="{'width':'70rpx'}"
								v-model="length" inputAlign="center"></u-input>

							宽(CM)
							<u-input type="number" placeholder="CM" border="bottom" :customStyle="{'width':'70rpx'}"
								v-model="width" inputAlign="center"></u-input>

							高(CM)
							<u-input type="number" placeholder="CM" border="bottom" :customStyle="{'width':'70rpx'}"
								v-model="height" inputAlign="center"></u-input>
						</view>
					</view>
				</u-cell>
				<!-- 		<u-cell :border="false" title="系统估价" :customStyle="{'padding':'20rpx 0rpx;'}">
					<view slot="right-icon">
				

						<view class="flex-center items-center" style="font-size: 24rpx;color:indianred;">

							￥
							<u-input type="number" placeholder="元" border="bottom" :customStyle="{'width':'70rpx'}"
								v-model="height" inputAlign="center"></u-input>
						</view>

					</view>
				</u-cell> -->
				<!-- <u-cell :border="false" title="优惠券" :customStyle="{'padding':'20rpx 0rpx;'}">
					<view slot="right-icon">
						<u-icon name="arrow-right" label="您有1张优惠券可选" labelPos="left" size="16"></u-icon>
					</view>
				</u-cell> -->
			</u-cell-group>
			<!-- <view class="flex-center"
				style="width:96%;margin:0 auto;color:indianred;font-size: 26rpx;border-radius: 20rpx;margin-top: 20rpx;padding:10rpx 0rpx;">
				如果重量存在误差会导致运费计算不精确,快递方收件后可能会额外收取运费,该费用平台会通知您进行补差
			
			</view> -->
		</view>

		<view class="template-view" v-if="totalPrice">
			<u-cell-group :border="false">

				<u-cell :border="false" title="系统估价" :customStyle="priceType!=1?select_price_no: select_price"
					@click="checkPrice(1)">
					<view slot="right-icon">
						<!-- <u-number-box v-model="weight" @change="valChange" color="indianred" iconStyle="indianred">
						</u-number-box> -->

						<view class="flex-center items-center" style="font-size: 34rpx;color:black;font-weight: 700;">

							￥
							<text>{{totalPrice}}</text>
						</view>

					</view>
				</u-cell>

				<u-cell :border="false" title="一口价" :customStyle="priceType!=2?select_price_no: select_price"
					style="background-color: rebeccapurple;" @click="checkPrice(2)">
					<view slot="right-icon">
						<!-- <u-number-box v-model="weight" @change="valChange" color="indianred" iconStyle="indianred">
						</u-number-box> -->

						<view class="flex-center items-center" style="font-size: 34rpx;color:black;font-weight: 700;">


							<text>{{oneSurePrice?'￥'+oneSurePrice:'无'}}</text>
							<!-- <u-input type="number" placeholder="元" border="bottom" :customStyle="{'width':'70rpx'}"
								v-model="height" inputAlign="center"></u-input> -->
						</view>

					</view>

				</u-cell>




			</u-cell-group>
			<view style="display: flex;justify-content: center;">
				<view style="width: 60%;margin-right: 20rpx;">
					<u-button type="primary" text="确认下单" @click="createOrder"></u-button>
				</view>
				<!-- <view>
					<u-button type="success" text="预约用车" @click="createOrderTime"></u-button>
				</view> -->


			</view>
			<view class="flex-center"
				style="width:96%;margin:0 auto;color:indianred;font-size: 26rpx;border-radius: 20rpx;margin-top: 20rpx;padding:10rpx 0rpx;">
				如果体积存在误差会导致运费计算不精确,司机方收件后可能会额外收取运费,该费用平台会通知您进行补差
				<!-- <u-icon name="info-circle-fill" color="#fff" label="请确保重量和体积正确无误,如果存在误差会导致运费计算不正确,快递方收件后会额外收取运费,该费用平台会通知您进行补差" labelColor="#fff"
					labelSize="12"></u-icon> -->
			</view>
		</view>

		<view class="flex-center items-center"
			style="width:100%;margin:0 auto;color:#999;text-align: center;padding-top:20rpx;font-size: 26rpx;">
			<view style="width:6%;">
				<u-radio-group @change="groupChange" v-model="xieyi">
					<u-radio shape="circle" name="success" activeColor="#3c9cff"></u-radio>
				</u-radio-group>
			</view>
			<view>
				我已阅读并同意<label style="color:blue;" @click="$uti.toPage('/pages/xieyi')">《用户协议》</label>
			</view>

		</view>

		<view class="template-view" v-if="logList && logList.length>0">
			<u-cell-group :border="false">
				<u-cell v-for="(item,index) in logList" :key="index" :border="false" :icon="item.icon"
					:customStyle="{'padding':'20rpx 0rpx;'}"
					:iconStyle="{'width':'60rpx','height':'60rpx','border-radius':'50%'}">
					<view slot="label" style="font-size: 30rpx;color:#000;margin-left: 10rpx;">
						{{item.name}}
					</view>
					<view slot="label" style="font-size: 26rpx;color:#999;margin-left: 10rpx;">
						预估金额：<label style="color:indianred;">￥{{item.totalFee}}</label>
					</view>
					<view slot="right-icon">
						<u-tag text="下单" size="mini" type="primary" @click="createOrder(item.shipperCode)"></u-tag>
					</view>
				</u-cell>
			</u-cell-group>
		</view>
		<!-- <view class="template-view" style="color:#999;font-size: 24rpx;text-align: center;" v-else>
			选择寄件收件地址后系统自动读取快递公司信息
		</view> -->

		<u-divider text="合肥蓬山信息技术有限公司提供技术支持" :dashed="true"></u-divider>

		<image src="/static/service.png" style="width:120rpx;height: 150rpx;position: fixed;bottom: 50rpx;left:20rpx"
			@click="makePhone"></image>

		<!-- 判断用户有没有登录 -->
		<!-- <u-popup mode="bottom" :show="!isLogin" round="10">
			<login @success="loginClose" :userPid="uid"></login>
		</u-popup> -->

		<!-- <u-picker :show="show" :columns="columns" @confirm="firmPicker" @cancel="show=false"></u-picker> -->
		<!-- 选择用车类型 -->
		<u-popup :show="show" mode="bottom" @close="close" @open="open">
			<view class="_select_car">
				<u-tabs :list="carTypeList" @click="clickTabs" :current="0" :keyName="'vehicleClassesName'"
					lineWidth="30" lineColor="#f56c6c" :activeStyle="{
				            color: '#303133',
				            fontWeight: 'bold',
				            transform: 'scale(1.05)'
				        }" :inactiveStyle="{
				            color: '#606266',
				            transform: 'scale(1)'
				        }" itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;">


				</u-tabs>

				<view class="flex-center" style="margin-top: 50rpx;margin-bottom: 50rpx;">

					<view v-for="(item,index) in carSonTypeList"
						:class="{'item_select':item.isSelect==1,'item_select_no':item.isSelect==0}"
						@click="selectCar(item,index)">
						<!-- <u-checkbox v-model="item.isSelect == 0 : false ? true"
							:customStyle="{position:'absolute',right:'-5px'}"></u-checkbox> -->

						<!-- <u-checkbox-group v-model="item.isSelect==0?true:false">
							<u-checkbox 
								:customStyle="{position:'absolute',right:'-5px'}"></u-checkbox>
						</u-checkbox-group> -->
						<view style="position: absolute;top:25rpx;left:34rpx">
							<u--image :showLoading="true" :src="src" width="60px" height="40px"></u--image>
							<p style="margin-top: 10rpx;font-size: 28rpx;">{{item.vehicleTypeName}}</p>
						</view>


					</view>

				</view>



				<view style="text-align: center;margin-left: 12%;margin-bottom: 50rpx;">

					<!-- <view style="background-color: #999;width: 50%;">
						<span></span>
					</view> -->
					<!-- <u-tabs  lineColor="transparent" itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;" :activeStyle="{color: '#303133',}"
						:inactiveStyle="{color: '#303133',}" :list="list1" >
							
					</u-tabs> -->
					<view>
						<span class="item_text" style="color: #999;">厢长</span>
						<span class="item_text" style="color: #999;">载方</span>
						<span class="item_text" style="color: #999;">载重</span>
					</view>
					<view>
						<span class="item_text" style="font-weight: 700;">{{currentItem.carLength}}</span>
						<span class="item_text" style="font-weight: 700;">{{currentItem.volume}}</span>
						<span class="item_text" style="font-weight: 700;">{{currentItem.nuclear}}</span>
					</view>

				</view>


				<view style="display: flex;justify-content: center;">
					<!-- <u-button type="primary" size="small" text="确定" ></u-button> -->
					<!-- <u-button class="custom-style" text="雪月夜"></u-button> -->
					<view style="margin-right: 20rpx;">
						<u-button type="primary" @click="firmPicker" size="small" text="确定"></u-button>
					</view>
					<view style="margin-left: 20rpx;">
						<u-button type="warning" @click="close" size="small" text="取消"></u-button>
					</view>
					<!-- <u-button type="primary" size="small" text="取消"></u-button> -->
				</view>


			</view>
		</u-popup>
		<!-- 一口价填写价格 -->
		<u-popup :show="showPrice" mode="bottom" @close="close" @open="open">
			<view style="text-align: center;">
				<view style="font-size: 40rpx;font-weight: 600;padding: 30rpx;">一口价</view>
				<view style="width: 50%;margin-left: 25%;margin-top: 30rpx;">
					<u--input placeholder="请输入一口价" border="bottom" v-model="onePrice" @change="change"></u--input>
				</view>
				<view style="width: 50%;margin-left: 25%;margin-top: 60rpx;">

					<u-button type="primary" text="确定" @click="sureOnePrice"></u-button>

				</view>
			</view>


		</u-popup>
		<u-notify ref="uNotify"></u-notify>

		<u-datetime-picker ref="datetimePicker" :formatter="formatter" :show="showDate" @confirm="firmPickerTimer"
			@cancel="closeDate" v-model="dateDataS" mode="datetime"></u-datetime-picker>
	</view>
</template>

<script>
	import login from '../../components/login/login.vue'

	export default {
		components: {
			login
		},
		data() {
			return {
				show: false,
				src: 'https://cdn.uviewui.com/uview/album/1.jpg',
				list1: [{
					name: '厢长',
				}, {
					name: '载方',
				}, {
					name: '载重'
				}],
				showDate: false,

				showNotify: false,
				showPrice: false,
				select_price: {
					'padding': '35rpx',
					'border-radius': '40rpx',
					'border': '#03a9f4 solid 1rpx',
					'margin-bottom': '20rpx'
				},
				select_price_no: {
					'padding': '35rpx',
					'border-radius': '40rpx',
					'border': '#999 solid 1rpx',
					'margin-bottom': '20rpx'
				},
				checkboxValue1: [],
				// 基本案列数据
				checkboxList1: [{
						name: '苹果',
						disabled: false
					},
					{
						name: '香蕉',
						disabled: false
					},
					{
						name: '橙子',
						disabled: false
					}
				],
				columns: [
					['日用品', '文件', '化妆品', '图书', '衣服鞋帽', '箱包', '其他']
				],
				currentItem: {},
				distance: undefined,
				carTypeList: [],
				carSonTypeList: [],
				file: '请选择',
				totalPrice: undefined,
				onePrice: undefined,
				oneSurePrice: undefined,
				length: 1,
				width: 1,
				height: 1,
				priceType: 1,
				isLogin: true,
				xieyi: 'null',
				weight: 1,
				dateData: undefined,
				dateDataS:Number(new Date()) ,
				noticeList: ['加盟代理请联系：zs9527gblw', '使用途中出现任何问题请联系客服'],
				seller: [],
				query: [],
				reason: '',
				logList: [],
				uid: 0
			}
		},
		onLoad(options) {
			var that = this;
			console.log("-=-=-=-=-=-=-=-=-=-=-=-=")
			this.init();
			that.isLogin = that.$us.checkLogin();
			if (that.isLogin) {
				this.uid = options.uid || 0;

				this.init();
				uni.showShareMenu({
					withShareTicket: true,
					menus: ["shareAppMessage", "shareTimeline"]
				})
			}

			// console.log('是否登陆', that.isLogin)
		},
		onShow() {
			var that = this;
			that.isLogin = that.$us.checkLogin();
			that.dateData = undefined;
		},
		onReady() {
			// 微信小程序需要用此写法
			this.$refs.datetimePicker.setFormatter(this.formatter)
		},
		methods: {
			init() {

				var that = this;
				that.isLogin = that.$us.checkLogin();

				let currentItem = uni.getStorageSync('filePicker');
				if (currentItem) {
					let str = currentItem.vehicleClassesName
					let typeStr = ''
					currentItem.classType.map(item => {
						if (item.isSelect) {
							typeStr += item.vehicleTypeName
						}
					})
					str = str + '(' + typeStr + ')';
					this.file = str;
				} else {
					that.file = '请选择';
				}


				if (that.isLogin) {
					that.reloadAddress('seller');
					that.reloadAddress('query');
				}

				this.getAllCarType();

				this.xieyi = uni.getStorageSync('xieyi') || 'null';
			},
			firmPickerTimer(val) {
				console.log(val,"======");
				if(val){
					// this.dateData = this.$uti.dateFormat(val.value,'yyyy-mm-dd hh:MM:ss')
					this.$set(this,'dateData',this.$uti.dateFormat(val.value,'yyyy-mm-dd hh:MM:ss'))
				}
				
				console.log(this.dateData,"----")
				this.showDate = false;
			},
			checkPrice(type) {
				this.priceType = type;
				if (type == 2) {
					this.showPrice = true;
				}
			},
			closeDate() {
				this.showDate = false;
			},
			showTimerType() {
				this.showDate = true;
			},
			//计算价格
			numberPirce() {

				var that = this;

				// userGuid: that.$us.getId()
				if (this.distance && this.distance > 0) {
					that.$http.get('order/calculate/' + this.distance, {

					}, function(res) {
						if (res.data.code == 200) {
							that.totalPrice = res.data.data;
						}
					})
				} else {
					this.$refs.uNotify.show({

						type: 'error',


						message: '请选择正确的地址！',
						duration: 1000 * 3,

						// safeAreaInsetTop: true
					})
				}


			},
			showCarType() {
				console.log('open');
				// this.currentItem = uni.getStorageSync('filePicker');
				this.show = true;
				console.log(this.currentItem);
			},
			open() {
				console.log('open');
				// this.currentItem = uni.getStorageSync('filePicker');
				console.log(this.currentItem);
			},
			close() {
				this.show = false;
				this.showPrice = false;
				// console.log('close');
			},
			change(e) {
				console.log('change', e);
			},
			clickTabs(item) {
				console.log(item, "itemitemitemitem")
				this.currentItem = item;
				this.carSonTypeList = item.classType
			},
			selectCar(item, index) {
				this.carSonTypeList[index].isSelect = !this.carSonTypeList[index].isSelect
				console.log(this.carSonTypeList, "this.carSonTypeList");
			},
			sureOnePrice() {

				this.showPrice = false;
				// this.oneSurePrice = this.onePrice;
				this.$set(this, "oneSurePrice", this.onePrice)
			},
			//获取车辆类型
			getAllCarType() {
				console.log("-----")
				let that = this;

				that.$http.get('vehicle', {

				}, function(res) {
					if (res.code == 200) {
						// res.Data.forEach(item => {
						// 	item.show = false;
						// 	that.list.push(item);
						// })
						if (res.data.length > 0) {
							that.carTypeList = res.data
							that.carSonTypeList = res.data[0].classType
							that.currentItem = res.data[0];
						}

						// that.list = res.data.data.list
						// console.log('地址列表', that.list)
					}
				})

			},






			firmPicker(e) {
				console.log('firmPicker', this.currentItem, this.carSonTypeList)
				let str = this.currentItem.vehicleClassesName
				let typeStr = ''
				this.currentItem.classType.map(item => {
					if (item.isSelect) {
						typeStr += item.vehicleTypeName
					}
				})
				str = str + '(' + typeStr + ')';
				this.file = str;
				uni.setStorageSync('filePicker', this.currentItem);
				this.show = false;

				this.numberPirce();

				// this.currentItem


				// this.file = e.value[0];
				// uni.setStorageSync('filePicker', e.value[0]);
				// this.show = false;
			},
			loginClose() {
				// this.isLogin = true;
				this.init();
			},
			groupChange(e) {
				console.log(e);
				this.xieyi = e;
				uni.setStorageSync('xieyi', this.xieyi)
			},
			reloadAddress(name) {
				console.log(name, "=======")
				var that = this;
				if (name == 'none') {
					that.$uti.alert('无效选择');
					return;
				}
				this[name] = uni.getStorageSync(name) || [];

				// console.log(this.seller, "this.seller");


				if (this.seller && this.seller.id && this.query && this.query.id) {
					console.log(this.seller, this.query)

					this.distance = this.getDistance(this.seller.adLatitude, this.seller.adLongitude, this.query
						.adLatitude,
						this.query
						.adLongitude);
					let currentItem = uni.getStorageSync('filePicker');
					if (currentItem) {
						this.numberPirce();
					}

					// console.log('距离：', distance, '千米');
					// that.$http.post('Order/AreaVerification', {
					// 	r_ProvinceName: that.query.adProvince,
					// 	r_CityName: that.query.adCity,
					// 	r_ExpAreaName: that.query.adArea,
					// 	r_Address: that.query.adDetail + that.query.adHouseNumber,
					// 	s_ProvinceName: that.seller.adProvince,
					// 	s_CityName: that.seller.adCity,
					// 	s_ExpAreaName: that.seller.adArea,
					// 	s_Address: that.seller.adProvince + that.seller.adHouseNumber,
					// }, function(data) {
					// 	var res = JSON.parse(data.Data);
					// 	that.reason = res.Success ? '' : res.Reason;
					// })

					// that.getEstimatedFreight();
				}
			},

			getDistance(lat1, lon1, lat2, lon2) {
				const R = 6371; // 地球半径，单位为千米
				const dLat = (lat2 - lat1) * Math.PI / 180;
				const dLon = (lon2 - lon1) * Math.PI / 180;
				const a =
					Math.sin(dLat / 2) * Math.sin(dLat / 2) +
					Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
					Math.sin(dLon / 2) * Math.sin(dLon / 2);
				const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
				const distance = R * c;
				return distance.toFixed(2); // 保留两位小数
			},
			valChange(e) {
				console.log('当前值为: ' + e.value);
				this.weight = e.value;
				this.getEstimatedFreight();
			},
			getEstimatedFreight() {
				var that = this;
				that.logList = [];
				if (that.seller && that.seller.id && that.query && that.query.id) {
					that.$http.post('Order/EstimatedFreight', {
						userGuid: that.$us.getId(),
						Weight: that.weight,
						r_CityName: that.query.adCity,
						r_ProvinceName: that.query.adProvince,
						s_ProvinceName: that.seller.adProvince,
						s_CityName: that.seller.adCity
					}, function(res) {
						if (res.StatusCode == 1) {
							//console.log('getEstimatedFreight', res.Data)
							res.Data.forEach(item => {
								var data = that.$cfg.logList.find(_ => _.key == item.shipperCode);
								if (data) {
									item.icon = data.icon;
									item.name = data.name;
									that.logList.push(item);
								}
							})
						} else {
							that.$uti.alert(res.Message);
						}
						console.log('getEstimatedFreight', that.logList)
					}, '加载中...')
				}
			},
			createOrderTime() {

				// var that = this;
				// console.log('协议', that.xieyi)
				// if (that.xieyi != 'success') {
				// 	that.$uti.alert('请阅读并同意用户协议');
				// 	return;
				// }



				// if (!that.currentItem) {
				// 	that.$uti.alert('请选择车辆');
				// 	return;
				// }
				this.showDate = true;
				// this.$refs.datetimePicker.setFormatter(this.formatter)

			},
			createOrder(code) {
				var that = this;
				console.log('协议', that.xieyi)
				if (that.xieyi != 'success') {
					that.$uti.alert('请阅读并同意用户协议');
					return;
				}

				if (!that.currentItem) {
					that.$uti.alert('请选择车辆');
					return;
				}

				console.log(that.currentItem, "==");

				// that.values.find(_ => _.key == 'userName').value = res.name;
				// that.values.find(_ => _.key == 'detailed').value = res.details;
				// that.values.find(_ => _.key == 'adHouseNumber').value = '';
				// that.values.find(_ => _.key == 'phone').value = res.phone;
				// uni.hideLoading();
				// that.$us.getId()
				if (this.seller && this.seller.id && this.query && this.query.id) {

					let ids = [];
					that.currentItem.classType.map(item => {
						if (item.isSelect) {
							ids.push(item.id)
						}
					})
					ids = ids.join(',')
					console.log(that.dateData,"shijian")
					that.$http.post('order', {
						"customerId": "1",
						"pickupAddress": that.query.detailed,
						"deliveryAddress": that.seller.detailed,
						"kilometer": that.distance,
						"price": that.totalPrice,
						"pickPhone": that.query.phone,
						"pickupCity": that.query.city,
						"pickupProvince": that.query.state,
						"pickupStreet": that.query.street,
						"pickName": that.query.userName,
						"deliveryCity": that.seller.city,
						"deliveryStreet": that.seller.street,
						"deliveryName": that.seller.userName,
						"appointmentTime":that.dateData ,
						"deliveryProvince": that.seller.state,
						"pDLatitude": that.query.adLatitude,
						"pDLongitudee": that.query.adLongitude,
						"deliveryPhone": that.seller.phone,
						"deAdLatitude": that.seller.adLatitude,
						"deAdLongitude": that.seller.adLongitude,
						"vehicleClassesId": that.currentItem.id,
						"classTypes": ids,
						"goodsLong": that.length,
						"goodsWidth": that.width,
						"goodsHigh": that.height,
						"kilPrice": that.onePrice | '', //一口价
						"remark": "测试订单"
					}, function(res) {

						that.$uti.toPage('/pages/order/orderDetils/orderDetils', {
							orderId: res.data.data.id
						})
						// if (res.StatusCode == 1) {
						// 	that.weChatPay(res.Data);
						// } else {
						// 	that.$uti.alert(res.Message);
						// }
					}, '创建订单中...')
				} else {
					that.$uti.alert('请先选择地址');
				}
			},
			formatter(type, value) {
				// console.log(type,value);
				if (type === 'year') {
					return `${value}年`
				}
				if (type === 'month') {
					return `${value}月`
				}
				if (type === 'day') {
					return `${value}日`
				}

				// if (type === 'hour') {
				// 	return `${value}时`
				// }
				// if (type === 'minute') {
				// 	return `${value}分`
				// }
				return value
			},
			weChatPay(data) {
				uni.requestPayment({
					provider: 'wxpay',
					nonceStr: data.nonceStr,
					package: data.package,
					paySign: data.paySign,
					signType: data.signType,
					timeStamp: data.timeStamp,
					success: (res) => {
						console.log('success:' + JSON.stringify(res));
						uni.showToast({
							title: '支付成功！',
							duration: 2000
						});
						uni.reLaunch({
							url: '/pages/order/list'
						})
					},
					fail: (err) => {
						console.log('fail:' + JSON.stringify(err));
						uni.showToast({
							title: '已取消支付！',
							icon: 'none',
							duration: 2000
						});
					}
				});
			}
		},
		onShareAppMessage(res) {
			let that = this;
			var title = '这里寄快递超便宜,5块钱起寄全国,赶紧收藏起来';
			let imageUrl = '/static/share.jpg';
			if (res.from === 'button') {
				//这块需要传参，不然链接地址进去获取不到数据
				return {
					title: title,
					path: '/pages/index/index?uid=' + that.$us.getId(),
					imageUrl: imageUrl
				};
			}
			if (res.from === 'menu') {
				return {
					title: title,
					path: '/pages/index/index' + that.$us.getId(),
					imageUrl: imageUrl
				};
			}
		},
		// 分享到朋友圈
		onShareTimeline() {
			let imageUrl = '/static/share.jpg';
			return {
				title: title,
				path: '/pages/index/index' + that.$us.getId(),
				imageUrl: imageUrl
			};
		}
	}
</script>

<style>
	@import url('index.css');
</style>